/**
* 合同详情
*/
<template>
	<view class="container">
		<u-form :model="form" ref="uForm" label-width="200">
			<u-form-item label="合同名称">
				<u-input v-model="form.contractName" disabled />
			</u-form-item>
			<u-form-item label="合同起源">
				<u-input v-model="form.contractOrigin_dictText" disabled />
			</u-form-item>
			<u-form-item v-show="show" :label="title">
				<u-input v-model="content" disabled />
			</u-form-item>
			<u-form-item label="合同业务类型">
				<u-input v-model="form.sparefield01" disabled />
			</u-form-item>
			<u-form-item label="合同金额">
				<u-input v-model="form.contractCount" disabled />
			</u-form-item>
			<u-form-item label="收付方向">
				<u-input v-model="form.getSend_dictText" disabled />
			</u-form-item>
			<u-form-item label="甲方单位">
				<u-input v-model="form.buyeIdA_dictText" disabled />
			</u-form-item>
			<u-form-item label="甲方代理人">
				<u-input v-model="form.agentA" disabled />
			</u-form-item>
			<u-form-item label="甲方联系方式" v-if="disabled">
				<u-input v-model="form.agentAContact" :disabled="disabled" />
			</u-form-item>
			<u-form-item label="乙方单位">
				<u-input v-model="form.buyeIdB_dictText" disabled />
			</u-form-item>
			<u-form-item label="乙方代理人">
				<u-input v-model="form.agentB" disabled />
			</u-form-item>
			<u-form-item label="乙方联系方式">
				<u-input v-model="form.agentBContact" disabled />
			</u-form-item>
			<u-form-item label="合同开始时间">
				<u-input v-model="form.contractStart" disabled />
			</u-form-item>
			<u-form-item label="合同截至时间">
				<u-input v-model="form.contractEnd" disabled />
			</u-form-item>
			<u-form-item label="签订时间">
				<u-input v-model="form.contractAwardDate" disabled />
			</u-form-item>
			<u-form-item label="状态">
				<text :class="[
				  form.status !== '执行中' ? 'noDone' : 'done',
				]">
					{{form.status}}
				</text>
			</u-form-item>
			<u-form-item label="合同内容摘要">
				<view class="" v-html="form.contractContentMain">

				</view>
			</u-form-item>
		</u-form>
	</view>
</template>

<script>
	import hetongApi from "../../api/hetong.js"
	export default {
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		mounted() {
			console.log("this.$Route.query", this.$Route.query)
			// this.disabled = this.$Route.query.current ? true : false
			console.log("this.disabled", this.disabled)
			const {
				contractName,
				contractOrigin,
				agentA,
				buyeIdB_dictText,
				agentBContact,
				contractCount,
				contractStart,
				contractAwardDate,
				contractEnd,
				contractOrigin_dictText,
				getSend_dictText,
				buyeIdA_dictText,
				agentAContact,
				agentB,
				status,
				contractType,
				chanceId_dictText,
				contractParentId_dictText,
				acceptanceLetterId_dictText,
				contractContentMain,
				sparefield01

			} = this.$Route.query.obj

			this.title = contractOrigin_dictText

			this.form.contractName = contractName || '无'
			this.form.contractOrigin = contractOrigin || '无'
			this.form.agentA = agentA || '无'
			this.form.buyeIdB_dictText = buyeIdB_dictText || '无'
			this.form.contractCount = contractCount || '无'
			this.form.contractStart = contractStart || '无'
			this.form.contractAwardDate = contractAwardDate || '无'
			this.form.contractEnd = contractEnd || '无'
			this.form.contractOrigin_dictText = contractOrigin_dictText || '无'
			this.form.getSend_dictText = getSend_dictText || '无'
			this.form.buyeIdA_dictText = buyeIdA_dictText || '无'
			this.form.agentAContact = agentAContact || '无'
			this.form.agentBContact = agentBContact || '无'
			this.form.agentB = agentB || '无'
			this.form.contractType = contractType || '无'
			this.form.status = 1 ? '签订中' : '执行中'
			this.form.chanceId_dictText = chanceId_dictText || '无'
			this.form.contractParentId_dictText = contractParentId_dictText || '无'
			this.form.acceptanceLetterId_dictText = acceptanceLetterId_dictText || '无'
			this.form.contractContentMain = contractContentMain || '无'
			this.form.sparefield01 = sparefield01 || '无'
			if (this.form.contractOrigin == 4) {
				this.show = false
			}
			if (this.form.contractOrigin == 1) {
				this.content = this.form.chanceId_dictText
			} else {
				if (this.form.contractOrigin == 2) {
					this.content = this.form.acceptanceLetterId_dictText
				} else {
					if (this.form.contractOrigin == 3) {
						this.content = this.form.contractParentId_dictText
					}
				}
			}

			console.log(this.content)
			hetongApi.getHeTongDetail({
				'X-Access-Token': this.$store.state.token
			}, {
				id: this.$Route.query.obj.id,
				// tableName: this.$Route.query.obj.tableName,
			}).then(res => {
				let {
					reasonForLeave,
					leaveApplicant,
					deadlineForLeave,
					leaveStartTime
				} = res.data.result
				this.form.reasonForLeave = reasonForLeave
				this.form.leaveApplicant = leaveApplicant
				this.form.deadlineForLeave = deadlineForLeave
				this.form.leaveStartTime = leaveStartTime
				console.log("111", res)
			}).catch(err => {
				console.log(err)
			})
		},
		data() {
			return {
				content: '',
				show: true,
				title: '',
				form: {
					contractName: '',
					contractOrigin: '',
					agentA: '',
					buyeIdB_dictText: '',
					agentBContact: '',
					contractCount: '',
					contractStart: '',
					contractAwardDate: '',
					contractEnd: '',
					contractOrigin_dictText: '',
					getSend_dictText: '',
					status: '',
					chanceId_dictText: '',
				},
				// 判断是否可写
				disabled: false,
				// 请假离开时间是否显示
				leaveShow: false,
				// 请假截止时间是否显示
				deadlineShow: false,
				// 日历模式
				mode: 'date',
				// 弹出框的显示
				popupShow: false,
				// 弹出框内表单数据
				passForm: {
					// 审批意见
					suggestion: ''
				},
				// 弹出框内表单checkbox数据
				checkboxList: [{
						name: '站内消息通知',
						checked: false,
						disabled: false
					},
					{
						name: '短信通知',
						checked: false,
						disabled: false
					},
					{
						name: '邮件通知',
						checked: false,
						disabled: false
					}
				],
			};
		},
		methods: {}
	};
</script>

<style scoped lang="scss">
	.container {
		width: 90%;
		margin: 0 auto;
	
	.btns {
			display: flex;
			justify-content: space-around;
			margin-top: 20px;
		}
	}
		.done{
		  color: #800080 !important;
		  font-weight: bold;
		}
		.noDone {
		  color: black !important;
		  font-weight: bold;
		}
</style>
